home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
dev
/
misc
/
IOBlixDevKitR2.lha
/
IOBlixDevKit
/
C
/
examples
/
QueryChipList.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-18
|
2KB
|
52 lines
/*
This program is meant to demonstrate how to get all necessary information
about all available chips on an IOBlix board in a system-friendly manner
*/
#include <exec/exec.h>
#include <resources/ioblix.h>
#include <stdio.h>
#include <string.h>
#include <proto/exec.h>
#include <proto/ioblix.h>
UBYTE __aligned myname[]="QueryChipList 37.1 "__AMIGADATE__;
UBYTE __aligned version[]="$VER: QueryChipList 37.1 "__AMIGADATE__;
UBYTE __aligned copyright[]="(C)opyright 1998,1999 by Thore Böckelmann and RBM Computertechnik. All rights reserved";
struct IOBlixResource *IOBlixBase = NULL;
void main(void)
{
struct List *chipList;
struct IOBlixChipNode *chipNode;
ULONG uartCnt, ppCnt, fifoCnt, otherCnt;
IOBlixBase = (struct IOBlixResource *)OpenResource(IOBLIXRESNAME);
if (IOBlixBase) {
/* try to get a copy of the global chip list */
chipList = AllocChipList();
if (chipList) {
uartCnt = ppCnt = fifoCnt = otherCnt = 0;
/* let's count all the available chips in the system */
for (chipNode = (struct IOBlixChipNode *)chipList->lh_Head; chipNode->icn_Node.ln_Succ; chipNode = (struct IOBlixChipNode *)chipNode->icn_Node.ln_Succ) {
switch (chipNode->icn_Type) {
case ICT_SERIAL_Z2_CHIP: uartCnt++; break;
case ICT_PARALLEL_Z2_CHIP: ppCnt++; break;
case ICT_EXTFIFO_Z2_CHIP: fifoCnt++; break;
default: otherCnt++; break;
}
}
printf("There are %ld UARTs, %ld parallel ports, %ld external FIFOs and %ld other chips in your system.\n", uartCnt, ppCnt, fifoCnt, otherCnt);
FreeChipList(chipList);
} else {
printf("Can't get a copy of the chip list!\n");
}
} else {
printf("Can't find ioblix.resource. Please run SetupIOBlix\n");
}
}